<template>
  <div id="app">
    <!-- 页眉部分 -->
    <header class="header">
      <div class="header-content">
        <!-- 左侧 Logo 和网站名称 -->
        <router-link to="/" class="left-section">
          <img src="@/assets/logo.png" alt="Logo" class="logo">
          <span class="site-name">古迹文物数字地图</span>
        </router-link>

        <!-- 右侧导航菜单 -->
        <nav class="right-section">
          <router-link to="/creator" class="nav-item creator-center">
            创作中心
          </router-link>

          <!-- 首页按钮及下拉菜单 -->
          <div class="nav-item" @mouseenter="showDropdown = true" @mouseleave="showDropdown = false">
            首页
            <!-- 下拉菜单 -->
            <div v-if="showDropdown" class="dropdown-menu">
              <router-link to="/map" class="dropdown-item">地图</router-link>
              <router-link to="/locations" class="dropdown-item">列表</router-link>
            </div>
          </div>

          <!-- 其他导航项 -->
          <router-link to="/display" class="nav-item">展示</router-link>
          <router-link to="/user" class="nav-item">用户</router-link>
        </nav>
      </div>
    </header>

    <!-- 路由视图 -->
    <div class="content-container">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      // 控制下拉菜单显示
      showDropdown: false
    };
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background-color: #f5f5f5;
  padding: 0 10px;
  height: 60px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.header-content {
  max-width: 98%;
  margin: 0 auto;
  height: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.left-section {
  display: flex;
  align-items: center;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.left-section:hover {
  opacity: 0.8;
}

.logo {
  height: 40px;
  width: 40px;
  margin-right: 10px;
  background-color: #666;
  border-radius: 4px;
}

.site-name {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}

.right-section {
  display: flex;
  gap: 20px;
  align-items: center;
  position: relative;
}

.nav-item {
  text-decoration: none;
  color: #333;
  padding: 8px 16px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.nav-item:hover {
  background-color: #e0e0e0;
}

.creator-center {
  background-color: #4CAF50;
  color: white;
}

.creator-center:hover {
  background-color: #45a049;
}

.content-container {
  margin-top: 60px;
  flex: 1;
  padding: 20px;
}

/* 下拉菜单样式 */
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: #fff;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  min-width: 160px;
  border-radius: 4px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
}

.dropdown-item {
  padding: 8px 16px;
  text-decoration: none;
  color: #333;
  transition: background-color 0.3s;
}

.dropdown-item:hover {
  background-color: #f0f0f0;
}
</style>